package com.pet.cloud.merchant.infrastructure.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pet.cloud.merchant.infrastructure.entity.User;
import com.pet.cloud.merchant.infrastructure.mapper.UserMapper;
import com.pet.cloud.merchant.infrastructure.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public User queryByUser(HashMap<String, Object> parse) {
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(User::getOpenId, parse.get("openId"));
        queryWrapper.eq(User::getUnionId, parse.get("unionId"));
        queryWrapper.eq(User::getStatus, 0);
        return userMapper.selectOne(queryWrapper);
    }

    @Override
    public void insert(User user) {
        userMapper.insert(user);
    }
}
